package com.xx.doublexchat.common.chat.dao;

import com.xx.doublexchat.common.chat.domain.entity.Room;
import com.xx.doublexchat.common.chat.mapper.RoomMapper;
import com.xx.doublexchat.common.chat.service.IRoomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 房间表 服务实现类
 * </p>
 *
 * @author xiaoXuan
 * @since 2024-02-29
 */
@Service
public class RoomDao extends ServiceImpl<RoomMapper, Room> {
    /**
     * 刷新最新时间
     *
     * @param roomId     房间id
     * @param msgId      消息id
     * @param activeTime 最新活跃时间
     */
    public void refreshActiveTime(Long roomId, Long msgId, Date activeTime) {
        lambdaUpdate().set(Room::getActiveTime, activeTime)
                .eq(Room::getId, roomId)
                .eq(Room::getLastMsgId, msgId)
                .update();
    }
}
